package com.cc.pojo.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;


/**
 * @author c.c
 * @Since 2023/3/30
 * @Description
 */

@AllArgsConstructor
@Getter
public enum DataBaseEnum {
  /**
   * varchar型
   **/
  VARCHAR("String"),
  CHAR("String"),
  INT("Integer"),
  BIT("Boolean"),
  DOUBLE("Double"),
  FLOAT("Float"),
  DECIMAL("BigDecimal"),
  BIGINT("BigInteger"),
  BLOB("byte[]"),
  DATE("Date"),
  DATETIME("Timestamp"),
  TIME("Time"),
  JSON("String"),
  LONGTEXT("String"),
  TEXT("String"),
  TINYTEXT("String"),
  TIMESTAMP("Timestamp"),
  TINYINT("Boolean"),
  MEDIUMTEXT("String"),
  SMALLINT("Integer"),

  ;

  private String propertyName;

  public static String getPropertyName(String type) {
    DataBaseEnum[] values = DataBaseEnum.values();
    for (DataBaseEnum value : values) {
      if (value.name().equalsIgnoreCase(type)) {
        return value.getPropertyName();
      }
    }
    throw new RuntimeException("数据库没有与之匹配的类型：" + type);
  }
}
